package com.ssy.lingxi.member.merchant.controller.feign;

import com.ssy.lingxi.common.response.Wrapper;
import com.ssy.lingxi.member.merchant.api.model.vo.inner.request.MemberFeignRelationVO;
import com.ssy.lingxi.member.merchant.api.model.vo.inner.request.MemberFeignSubordinateMemberVO;
import com.ssy.lingxi.member.merchant.api.model.vo.inner.request.MemberFeignUserIdVO;
import com.ssy.lingxi.member.merchant.api.model.vo.inner.response.*;
import com.ssy.lingxi.member.merchant.service.feign.IMemberDetailFeignService;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.List;

/**
 * 会员、用户信息相关内部Feign接口
 * @author 万宁
 * @version 2.0.0
 * @date 2021-06-03
 */
@RestController
@RequestMapping("/member/feign/detail")
public class MemberDetailFeignController {
    @Resource
    private IMemberDetailFeignService memberDetailFeignService;

    /**
     * 查询用户Web端菜单权限Url列表
     * @param userIdVO 接口参数
     * @return 查询结果
     */
    @RequestMapping(value = "/user/auth", method = RequestMethod.POST)
    public Wrapper<List<String>> getUserWebAuthUrls(@RequestBody @Valid MemberFeignUserIdVO userIdVO) {
        return memberDetailFeignService.getUserWebAuthUrls(userIdVO.getUserId());
    }

    /**
     * 根据会员id查询用户
     * @param memberIds 会员id
     * @return 查询结果
     */
    @RequestMapping(value = "/user/bymemberids", method = RequestMethod.POST)
    public Wrapper<List<MemberFeignMsgByMemberIdVO>> getUserByMemberId(@RequestBody List<Long> memberIds) {
        return memberDetailFeignService.getUserByMemberIds(memberIds);
    }

    /**
     * 根据角色id查询用户
     * @param roleIds 角色id
     * @return 查询结果
     */
    @RequestMapping(value = "/user/byroleids", method = RequestMethod.POST)
    public Wrapper<List<MemberFeignMsgByRoleIdVO>> getUserByRoleId(@RequestBody List<Long> roleIds) {
        return memberDetailFeignService.getUserByRoleIds(roleIds);
    }

    /**
     * 结算能力 - 查询下级会员入库分类信息中，主营品类及结算方式
     * @param relationVO 接口参数
     * @return 查询结果，如无配置返回空列表
     */
    @RequestMapping(value = "/classification/categories", method = RequestMethod.POST)
    public Wrapper<List<MemberCategoryFeignVO>> findMemberBusinessCategories(@RequestBody MemberFeignRelationVO relationVO) {
        return memberDetailFeignService.findMemberBusinessCategories(relationVO);
    }

    /**
     * 根据用户Id查询用户信息
     * @param idVO 接口参数
     * @return 查询结果
     */
    @RequestMapping(value = "/user", method = RequestMethod.POST)
    public Wrapper<MemberFeignUserDetailVO> findMemberUser(@RequestBody MemberFeignUserIdVO idVO) {
        return memberDetailFeignService.findMemberUser(idVO);
    }


    /**
     * 根据会员id和角色id，查询会员角色为服务提供者的下级会员列表
     * @param memberVO 上级会员信息
     * @return 查询结果
     */
    @RequestMapping(value = "/subordinate/member/list", method = RequestMethod.POST)
    public Wrapper<List<MemberManageQueryVO>> subordinateMemberList(@RequestBody MemberFeignSubordinateMemberVO memberVO) {
        return memberDetailFeignService.subordinateMemberList(memberVO);
    }
}
